import bus from '@/bus/index.js';
import * as CONSTANTS from '@/config/constants.js';

export const Mixin = {
  created: function () {
    bus.$on(CONSTANTS.EventEnum.MAPCREATED, (olMap) => {
      // make the OL map accesible in this component
      this.map = olMap
      this.LMap = olMap.getLMap()
      // if (this.map.$mapUtils == null) {
      //   this.map.$mapUtils = new MapUtils(this.map)
      //   this.$store.commit('mapState/setOlMap', this.map)
      // }
      if (this.onMapBound) {
        this.onMapBound()
      }
    })
  },

  destroyed: function () {
    this.map = null;
    this.LMap = null;
    bus.$off(CONSTANTS.EventEnum.MAPCREATED);
  },
}
